package com.richpencil.modules.system.service;

import com.richpencil.modules.system.domain.DictDetail;
import com.richpencil.modules.system.service.dto.DictDetailDTO;
import com.richpencil.modules.system.service.dto.DictDetailQueryCriteria;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;

import java.util.Map;

/**
*
* @date 2019-04-10
*/
@CacheConfig(cacheNames = "dictDetail")
public interface DictDetailService {

    /**
     * findById
     * @param id
     * @return
     */
    @Cacheable(key = "#p0")
    DictDetailDTO findById(Long id);

    /**
     * create
     * @param resources
     * @return
     */
    @CacheEvict(allEntries = true)
    DictDetailDTO create(DictDetail resources);

    /**
     * update
     * @param resources
     */
    @CacheEvict(allEntries = true)
    void update(DictDetail resources);

    /**
     * delete
     * @param id
     */
    @CacheEvict(allEntries = true)
    void delete(Long id);

    @Cacheable(keyGenerator = "keyGenerator")
    Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable);

    /**
     * 查询字典详情表，分隔字典值返回map
     * @param id 字典主表id
     * @param label 字典从表标签
     * @return
     */
    Map<String, Object> queryMapByDictId(Long id, String label);

    /**
     * 查询字典详情表，返回值string
     * @param id 字典主表id
     * @param label 字典从表标签
     * @return
     */
    String queryStrByDictId(Long id, String label);
}